package net.lab1024.sa.admin.module.business.yct.yctTeeth.controller;

import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.UsermembersAddForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.UsermembersQueryForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.UsermembersUpdateForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.vo.UsermembersVO;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.service.UsermembersService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 用户 Controller
 *
 * @Author zhangben
 * @Date 2024-12-18 09:52:35
 * @Copyright 20241218
 */

@RestController
@Tag(name = "用户")
public class UsermembersController {

    @Resource
    private UsermembersService usermembersService;

    @Operation(summary = "分页查询 @author zhangben")
    @PostMapping("/usermembers/queryPage")
    @SaCheckPermission("usermembers:query")
    public ResponseDTO<PageResult<UsermembersVO>> queryPage(@RequestBody @Valid UsermembersQueryForm queryForm) {
        return ResponseDTO.ok(usermembersService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author zhangben")
    @PostMapping("/usermembers/add")
    @SaCheckPermission("usermembers:add")
    public ResponseDTO<String> add(@RequestBody @Valid UsermembersAddForm addForm) {
        return usermembersService.add(addForm);
    }

    @Operation(summary = "更新 @author zhangben")
    @PostMapping("/usermembers/update")
    @SaCheckPermission("usermembers:update")
    public ResponseDTO<String> update(@RequestBody @Valid UsermembersUpdateForm updateForm) {
        return usermembersService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author zhangben")
    @PostMapping("/usermembers/batchDelete")
    @SaCheckPermission("usermembers:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return usermembersService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author zhangben")
    @GetMapping("/usermembers/delete/{membersId}")
    @SaCheckPermission("usermembers:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer membersId) {
        return usermembersService.delete(membersId);
    }
}
